#include <linux/init.h>
#include <linux/sched.h>
#include <linux/tty.h>
#include <linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

void tty_write_message(struct tty_struct *tty,char *msg)
{
  if (tty && tty->driver->ops->write)
    tty->driver-> ops->write(tty, msg, strlen(msg));
  return;
}


int hello_init(void)
{
  //  dump_stack();
  printk("%s %s %d\n",__FUNCTION__,__FILE__,__LINE__);
  char *msg = "Hello tty";
  printk("Hello world\n");
  printk("%s",__FUNCTION__);
  printk("\n");
  printk(KERN_INFO "The process is \"%s\" (pid %d)\n",current->comm, current->pid);

  printk("parent pid =%d(%s)\n",current->parent->pid,current->parent->comm);
  printk("current pid =%d(%s)\n",current->pid,current->comm);
  tty_write_message(current->signal->tty,msg);

  return 0;
}

void hello_exit(void)
{
  //  int i = 2;
  printk("Goodbye, cruel world\n");
  //  printk("i = %d",i);
  printk("\n");
}

module_init(hello_init);
module_exit(hello_exit);
